home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / obero / oberon_lib.lha / oberon-a / source1.lha / source / Amiga / Config.mod < prev    next >
Text File  |  1994-08-08  |  12KB  |  345 lines

  1. (***************************************************************************
  2.  
  3.      $RCSfile: Config.mod $
  4.   Description: Interface to expansion.library
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.2 $
  8.       $Author: fjc $
  9.         $Date: 1994/08/08 00:46:19 $
  10.  
  11.   Includes Release 40.15
  12.  
  13.   (C) Copyright 1985-1993 Commodore-Amiga, Inc.
  14.       All Rights Reserved
  15.  
  16.   Oberon-A interface Copyright © 1994, Frank Copeland.
  17.   This file is part of the Oberon-A Interface.
  18.   See Oberon-A.doc for conditions of use and distribution.
  19.  
  20. ***************************************************************************)
  21.  
  22. MODULE Config;
  23.  
  24. (*
  25. ** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
  26. ** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
  27. ** $V- OvflChk       $Z- ZeroVars
  28. *)
  29.  
  30. IMPORT E := Exec;
  31.  
  32. (*
  33. **      $VER: configregs.h 36.13 (15.2.91)
  34. **
  35. **      AutoConfig (tm) hardware register and bit definitions
  36. *)
  37.  
  38.  
  39. (*
  40. ** AutoConfig (tm) boards each contain a 32 byte "ExpansionRom" area that is
  41. ** read by the system software at configuration time.  Configuration of each
  42. ** board starts when the ConfigIn* signal is passed from the previous board
  43. ** (or from the system for the first board).  Each board will present it's
  44. ** ExpansionRom structure at location $00E80000 to be read by the system.
  45. ** This file defines the appearance of the ExpansionRom area.
  46. **
  47. ** Expansion boards are actually organized such that only one nybble per
  48. ** 16 bit word contains valid information.  The low nybbles of each
  49. ** word are combined to fill the structure below. (This table is structured
  50. ** as LOGICAL information.  This means that it never corresponds exactly
  51. ** with a physical implementation.)
  52. **
  53. ** The ExpansionRom space is further split into two regions:  The first 16
  54. ** bytes are read-only.  Except for the ertype field, this area is inverted
  55. ** by the system software when read in.  The second 16 bytes contain the
  56. ** control portion, where all read/write registers are located.
  57. **
  58. ** The system builds one "ConfigDev" structure for each board found.  The
  59. ** list of boards can be examined using the expansion.library/FindConfigDev
  60. ** function.
  61. **
  62. ** A special "hacker" Manufacturer ID number is reserved for test use:
  63. ** 2011 ($7DB).  When inverted this will look like $F824.
  64. *)
  65.  
  66. TYPE
  67.  
  68.   ExpansionRomPtr * = CPOINTER TO ExpansionRom;
  69.   ExpansionRom * = RECORD
  70.     type *         : E.BSET;  (* Board type, size and flags *)
  71.     product *      : E.UBYTE; (* Product number, assigned by manufacturer *)
  72.     flags *        : E.BSET;  (* Flags *)
  73.     reserved03 *   : E.UBYTE; (* Must be zero ($ff inverted) *)
  74.     manufacturer * : E.UWORD; (* Unique ID,ASSIGNED BY COMMODORE-AMIGA! *)
  75.     serialNumber * : E.ULONG; (* Available for use by manufacturer *)
  76.     initDiagVec *  : E.UWORD; (* Offset to optional "DiagArea" structure *)
  77.     reserved0c *   : E.UBYTE;
  78.     reserved0d *   : E.UBYTE;
  79.     reserved0e *   : E.UBYTE;
  80.     reserved0f *   : E.UBYTE;
  81.   END; (* ExpansionRom *)
  82.  
  83.  
  84. (*
  85. ** Note that use of the ecBaseAddress register is tricky.  The system
  86. ** will actually write twice.  First the low order nybble is written
  87. ** to the ecBaseAddress register+2 (D15-D12).  Then the entire byte is
  88. ** written to ecBaseAddress (D15-D8).  This allows writing of a byte-wide
  89. ** address to nybble size registers.
  90. *)
  91.  
  92. TYPE
  93.  
  94.   ExpansionControlPtr * = CPOINTER TO ExpansionControl;
  95.   ExpansionControl * = RECORD
  96.     interrupt *   : E.BSET;  (* Optional interrupt control register *)
  97.     z3HighBase *  : E.UBYTE; (* Zorro III   : Config address bits 24-31 *)
  98.     baseAddress * : E.UBYTE; (* Zorro II/III: Config address bits 16-23 *)
  99.     shutup *      : E.UBYTE; (* The system writes here to shut up a board *)
  100.     reserved14 *  : E.UBYTE;
  101.     reserved15 *  : E.UBYTE;
  102.     reserved16 *  : E.UBYTE;
  103.     reserved17 *  : E.UBYTE;
  104.     reserved18 *  : E.UBYTE;
  105.     reserved19 *  : E.UBYTE;
  106.     reserved1a *  : E.UBYTE;
  107.     reserved1b *  : E.UBYTE;
  108.     reserved1c *  : E.UBYTE;
  109.     reserved1d *  : E.UBYTE;
  110.     reserved1e *  : E.UBYTE;
  111.     reserved1f *  : E.UBYTE;
  112.   END; (* ExpansionControl *)
  113.  
  114. (*
  115. ** many of the constants below consist of a triplet of equivalent
  116. ** definitions: xxMASK is a bit mask of those bits that matter.
  117. ** xxBIT is the starting bit number of the field.  xxSIZE is the
  118. ** number of bits that make up the definition.  This method is
  119. ** used when the field is larger than one bit.
  120. **
  121. ** If the field is only one bit wide then the xxBxx and xxFxx convention
  122. ** is used (xxBxx is the bit number, and xxFxx is mask of the bit).
  123. *)
  124.  
  125. CONST
  126.  
  127. (* manifest constants *)
  128.   slotSize *              = 10000H;
  129.   slotMask *              = 0FFFFH;
  130.   slotShift *             = 16;
  131.  
  132. (* these define the free regions of Zorro memory space.
  133. ** THESE MAY WELL CHANGE FOR FUTURE PRODUCTS!
  134. *)
  135.  
  136.   expansionBase *         = 00E80000H;      (* Zorro II  config address *)
  137.   z3ExpansionBase *       = 0FF000000H;     (* Zorro III config address *)
  138.  
  139.   expansionSize *         = 00080000H;      (* Zorro II  I/O type cards *)
  140.   expansionSlots *        = 8;
  141.  
  142.   memoryBase *            = 00200000H;      (* Zorro II  8MB space *)
  143.   memorySize *            = 00800000H;
  144.   memorySlots *           = 128;
  145.  
  146.   z3ConfigArea *          = 40000000H;      (* Zorro III space *)
  147.   z3ConfigAreaEnd *       = 7FFFFFFFH;      (* Zorro III space *)
  148.   z3SizeGranularity *     = 00080000H;      (* 512K increments *)
  149.  
  150.  
  151.  
  152. (**** erType definitions (ttldcmmm) ***************************************)
  153.  
  154. CONST
  155.  
  156. (* erType board type bits -- the OS ignores "old style" boards *)
  157.   ertTypeMask *            = {6, 7};     (* Bits 7-6 *)
  158.   ertTypeBit *             = 6;
  159.   ertTypeSize *            = 2;
  160.   ertNewBoard *            = {6, 7};
  161.   ertZorroII *             = ertNewBoard;
  162.   ertZorroIII *            = {7};
  163.  
  164. (* other bits defined in erType *)
  165.   ertMemList *            = 5;   (* Link RAM into free memory list *)
  166.   ertDiagValid *          = 4;   (* ROM vector is valid *)
  167.   ertChainedConfig *      = 3;   (* Next config is part of the same card *)
  168.  
  169. (* erType field memory size bits *)
  170.   ertMemMask *             = {0..2};    (* Bits 2-0 *)
  171.   ertMemBit *              = 0;
  172.   ertMemSize *             = 3;
  173.  
  174.  
  175. (**** erFlags byte -- for those things that didn't fit into the type byte ****)
  176. (**** the hardware stores this byte in inverted form                       ****)
  177.  
  178. CONST
  179.  
  180.   erfMemSpace *          = 7;    (* Wants to be in 8 meg space. *)
  181.                                  (* (NOT IMPLEMENTED) *)
  182.  
  183.   erfNoShutup *          = 6;    (* Board can't be shut up *)
  184.  
  185.   erfExtended *          = 5;    (* Zorro III: Use extended size table *)
  186.                                  (*            for bits 0-2 of erType *)
  187.                                  (* Zorro II : Must be 0 *)
  188.  
  189.   erfZorroIII *          = 4;    (* Zorro III: must be 1 *)
  190.                                  (* Zorro II : must be 0 *)
  191.  
  192.   ertZ3SSMask *          = {0..3}; (* Bits 3-0.  Zorro III Sub-Size.  How *)
  193.   ertZ3SSBit *           = 0;      (* much space the card actually uses   *)
  194.   ertZ3SSSize *          = 4;      (* (regardless of config granularity)  *)
  195.                                    (* Zorro II : must be 0        *)
  196.  
  197.  
  198. (* ecInterrupt register (unused) ********************************************)
  199.  
  200. CONST
  201.  
  202.   eciIntena *             = 1;
  203.   eciReset *              = 3;
  204.   eciInt2Pend *           = 4;
  205.   eciInt6Pend *           = 5;
  206.   eciInt7Pend *           = 6;
  207.   eciInterrupting *       = 7;
  208.  
  209. (***************************************************************************
  210. **
  211. ** these are the specifications for the diagnostic area.  If the Diagnostic
  212. ** Address Valid bit is set in the Board Type byte (the first byte in
  213. ** expansion space) then the Diag Init vector contains a valid offset.
  214. **
  215. ** The Diag Init vector is actually a word offset from the base of the
  216. ** board.  The resulting address points to the base of the DiagArea
  217. ** structure.  The structure may be physically implemented either four,
  218. ** eight, or sixteen bits wide.  The code will be copied out into
  219. ** ram first before being called.
  220. **
  221. ** The daSize field, and both code offsets (daDiagPoint and daBootPoint)
  222. ** are offsets from the diag area AFTER it has been copied into ram, and
  223. ** "de-nibbleized" (if needed).  (In other words, the size is the size of
  224. ** the actual information, not how much address space is required to
  225. ** store it.)
  226. **
  227. ** All bits are encoded with uninverted logic (e.g. 5 volts on the bus
  228. ** is a logic one).
  229. **
  230. ** If your board is to make use of the boot facility then it must leave
  231. ** its config area available even after it has been configured.  Your
  232. ** boot vector will be called AFTER your board's final address has been
  233. ** set.
  234. **
  235. ****************************************************************************)
  236.  
  237. TYPE
  238.  
  239.   DiagAreaPtr * = CPOINTER TO DiagArea;
  240.   DiagArea * = RECORD
  241.     config *     : E.UBYTE; (* see below for definitions *)
  242.     flags *      : E.BSET;  (* see below for definitions *)
  243.     size *       : E.UWORD; (* the size (in bytes) of the total diag area *)
  244.     diagPoint *  : E.UWORD; (* where to start for diagnostics, or zero *)
  245.     bootPoint *  : E.UWORD; (* where to start for booting *)
  246.     name *       : E.UWORD; (* offset in diag area where a string *)
  247.                             (*   identifier can be found (or zero if no *)
  248.                             (*   identifier is present). *)
  249.  
  250.     reserved01 * : E.UWORD; (* two words of reserved data.  must be zero. *)
  251.     reserved02 * : E.UWORD;
  252.   END; (* DiagArea *)
  253.  
  254. (* daConfig definitions *)
  255. (*
  256. ** dacByteWide can be simulated using dacNibbleWide.
  257. *)
  258.  
  259. CONST
  260.  
  261.   dacBusWidth *    = 0C0X; (* two bits for bus width *)
  262.   dacNibbleWide *  = 00X;
  263.   dacByteWide *    = 40X; (* BUG: Will not work under V34 Kickstart! *)
  264.   dacWordWide *    = 80X;
  265.  
  266.   dacBootTime *    = 30X;    (* two bits for when to boot *)
  267.   dacNever *       = 00X;    (* obvious *)
  268.   dacConfigTime *  = 10X;    (* call daBootPoint when first configing *)
  269.                                 (*   the device *)
  270.   dacBindTime *    = 20X;    (* run when binding drivers to boards *)
  271.  
  272. (*
  273. **
  274. ** These are the calling conventions for the diagnostic callback
  275. ** (from daDiagPoint):
  276. **
  277. ** A7 -- points to at least 2K of stack
  278. ** A6 -- ExecBase
  279. ** A5 -- ExpansionBase
  280. ** A3 -- your board's ConfigDev structure
  281. ** A2 -- Base of diag/init area that was copied
  282. ** A0 -- Base of your board
  283. **
  284. ** Your board must return a value in D0.  If this value is NULL, then
  285. ** the diag/init area that was copied in will be returned to the free
  286. ** memory pool.
  287. *)
  288.  
  289.  
  290. (*
  291. **      $VER: configvars.h 36.14 (22.4.91)
  292. **
  293. **      Software structures used by AutoConfig (tm) boards
  294. *)
  295.  
  296.  
  297. (*
  298. ** At early system startup time, one ConfigDev structure is created for
  299. ** each board found in the system.  Software may seach for ConfigDev
  300. ** structures by vendor & product ID number.  For debugging and diagnostic
  301. ** use, the entire list can be accessed.  See the expansion.library document
  302. ** for more information.
  303. *)
  304.  
  305. TYPE
  306.  
  307.   ConfigDevPtr * = CPOINTER TO ConfigDev;
  308.   ConfigDev * = RECORD (E.Node)
  309.     cdFlags *   : E.BSET;             (* (read/write) *)
  310.     pad         : E.UBYTE;            (* reserved *)
  311.     rom *       : ExpansionRom;       (* copy of board's expansion ROM *)
  312.     boardAddr * : E.APTR;             (* where in memory the board was placed *)
  313.     boardSize * : E.ULONG;            (* size of board in bytes *)
  314.     slotAddr    : E.UWORD;            (* which slot number (PRIVATE) *)
  315.     slotSize    : E.UWORD;            (* number of slots (PRIVATE) *)
  316.     driver *    : E.APTR;             (* pointer to node of driver *)
  317.     nextCD *    : ConfigDevPtr;       (* linked list of drivers to config *)
  318.     unused      : ARRAY 4 OF E.ULONG; (* for whatever the driver wants *)
  319.   END; (* ConfigDev *)
  320.  
  321. CONST
  322.  
  323. (* cdFlags *)
  324.   cdShutup *      = 0;       (* this board has been shut up *)
  325.   cdConfigMe *    = 1;       (* this board needs a driver to claim it *)
  326.   cdBadMemory *   = 2;       (* this board contains bad memory *)
  327.  
  328.  
  329. (*
  330. ** Boards are usually "bound" to software drivers.
  331. ** This structure is used by GetCurrentBinding() and SetCurrentBinding()
  332. *)
  333.  
  334. TYPE
  335.  
  336.   CurrentBindingPtr * = CPOINTER TO CurrentBinding;
  337.   CurrentBinding * = RECORD
  338.     configDev *     : ConfigDevPtr; (* first configdev in chain *)
  339.     fileName *      : E.STRPTR;     (* file name of driver *)
  340.     productString * : E.STRPTR;     (* product # string *)
  341.     toolTypes *     : E.APTR;       (* tooltypes from disk object *)
  342.   END; (* CurrentBinding *)
  343.  
  344. END Config.
  345.